package com.ky.pro.java.rpc.hd.common.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ky.pro.java.rpc.hd.common.entity.FrozenAssets;
import com.ky.pro.java.rpc.hd.common.mapper.FrozenAssetsMapper;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资产冻结表 服务实现类
 * </p>
 *
 * @author Kevin Dummy
 * @since 2022-01-02
 */
@Service
public class FrozenAssetsRepository extends ServiceImpl<FrozenAssetsMapper, FrozenAssets> implements IService<FrozenAssets> {

    public FrozenAssets findFrozenAssetsByAccountIdAndCurrency(long accountId, int currency) {
        return baseMapper.selectOne(new QueryWrapper<FrozenAssets>()
                .eq("account_id", accountId)
                .eq("currency", currency));
    }

    public boolean updateFrozenAssetsByAccountId(long accountId, int currency, long amountToAdd) {
        return baseMapper.updateFrozenAssetsByAccountId(accountId, currency, amountToAdd) > 0;
    }

}
